/*******************************************************************************
 * Copyright (c) 2007 University of Oslo.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     University of Oslo - initial API and implementation
 *******************************************************************************/

package com.cea.papyrus.diagram.sequence.sedi.edit.command;


import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.GraphicalEditPart;

import com.cea.papyrus.diagram.sequence.sedi.figures.LifelineFigure;

/**
 * Command to select the decomposition "part" of a lifeline on a diagram.
 *
 * Input:
 * o AnyEditPart
 * o Target: the element to be selected
 * o selectForEdit: if true, a DirectEditRequest will be directed to the element
 * o selectDecomposition: if true (and selectForEdit is true), the 
 * 		DirectEditRequest will be directed to the PartDecomposition name.
 * 
 * Output:
 * None
 * 
 * @author frankd
 */
public class SelectLifelinePartCommand extends SelectPartCommand {
	private boolean selectDecomposition;
	
	public void setSelectDecomposition(final boolean select) {
		this.selectDecomposition = select;
	}
	
	protected Point getEditLocation(GraphicalEditPart editPart) {
		if (selectDecomposition) {
			LifelineFigure figure = (LifelineFigure) editPart.getFigure();
			Rectangle r = figure.getRefBounds();
			//figure.translateToParent(r);
			//figure.translateToAbsolute(r);
			return r.getLocation();
		}
		else
			return super.getEditLocation(editPart);
	}
	

}
